package sevensoft.结构型模式.代理模式.jdk动态代理;

import java.lang.reflect.Proxy;

public class ProxyFactory {

    private final Station station = new Station();

    public Sellable getProxy() {

        Sellable sellable = (Sellable) Proxy.newProxyInstance(
                station.getClass().getClassLoader(),
                station.getClass().getInterfaces(),
                (proxy, method, args) -> {
                    System.out.println("代理费用收取(jdk动态代理)");
                    return method.invoke(station,args);
                }
        );
        return sellable;
    }
}
